#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    unordered_map<string, int> mp;
    int sum = 0;
    for (int _ = 1; _ <= n; _++) {
        string name;
        int val;
        cin >> name >> val;
        mp[name] = val;
        sum += val;
    }
    string winner;
    int wv = sum / (n * 2);
    int value = INT_MAX;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        if (abs(it->second - wv) < value) {
            winner = it->first;
            value = abs(it->second - wv);
        }
    }
    cout << wv << " " << winner << endl;
    return 0;
}